---
apiVersion: v1
kind: Secret
metadata:
  namespace: {{ kubernetes_namespace }}
  name: "{{ kubernetes_deployment_name }}-secrets"
type: Opaque
data:
  secret_key: "{{ secret_key | b64encode }}"
  admin_password: "{{ admin_password | b64encode }}"
  pg_password: "{{ pg_password | b64encode }}"
  rabbitmq_password: "{{ rabbitmq_password | b64encode }}"
  rabbitmq_erlang_cookie: "{{ rabbitmq_erlang_cookie | b64encode }}"
  credentials_py: "{{ lookup('template', 'credentials.py.j2') | b64encode }}"
  environment_sh: "{{ lookup('template', 'environment.sh.j2') | b64encode }}"

{% if rabbitmq_use_ssl|default(False)|bool %}
---
apiVersion: v1
kind: Secret
metadata:
  namespace: {{ kubernetes_namespace }}
  name: "{{ kubernetes_deployment_name }}-rabbitmq-certs"
type: Opaque
data:
  rabbitmq_ssl_cert: "{{ lookup('file', rmq_cert_tempdir.path + '/server.crt') | b64encode }}"
  rabbitmq_ssl_key: "{{ lookup('file', rmq_cert_tempdir.path + '/server.key') | b64encode }}"
  rabbitmq_ssl_cacert: "{{ lookup('file', rmq_cert_tempdir.path + '/ca.crt') | b64encode }}"
  rabbitmq_ssl_combined: "{{ lookup('file', rmq_cert_tempdir.path + '/server-combined.pem') | b64encode }}"
{% endif %}
